﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Cipher.Web.Utils;

namespace Cipher.Web.Areas.Design.Controllers {
    public class CipherController : Controller {
        public CipherDataContext Context = new CipherDataContext();

        [HttpGet]
        public ActionResult Create() {
            bool pop = !string.IsNullOrEmpty(Request.QueryString["pop"]);

            List<SelectListItem> dataSources = (from c in Context.CipherDataSources
                                                      select new SelectListItem() {
                                                          Text = c.SourceName,
                                                          Value = c.SourceName
                                                      }).ToList();

            dataSources.Insert(0, new SelectListItem() { Text = "Select a data source", Value = "" });

            ViewBag.Layout = pop ? TemplateUtil.PopTemplateName : TemplateUtil.TemplateName;
            ViewBag.DataSources = dataSources;
            return View();
        }
    }
}